#设置cmake最低版本
cmake_minimum_required(VERSION 3.4.1)


add_subdirectory(qlibrary_mylib)
add_subdirectory(qfile_stdinprocess_helper)


#设置项目名称
project(tst_qtbase_auto_corelib)

#引入add_module模板文件
include(${ISSQTTESTROOTDIR}/cmake/add_module.cmake)

#设置测试类型，auto为自动测试，manual为手动测试,即test目录下的文件夹名
set(TEST_TYPE auto)
#设置模块名
set(MODULE qtbase)
#设置需要链接的模块
set(LinkQt Core Gui Widgets Network Concurrent OpenGL Sql Svg Quick Xml PrintSupport)
#设置需要链接的模块的私有模块
set(LinkQtPrivate Core Test Gui Widgets Sql Network OpenGL Concurrent PrintSupport)

add_definitions("-DQT_DISABLE_DEPRECATED_BEFORE=0"
                "-DSRCDIR=\"${CMAKE_CURRENT_SOURCE_DIR}/\"")
get_filename_component(CMAKE_NATIVE_MAKE_PROGRAM ${CMAKE_MAKE_PROGRAM} NAME)
add_definitions(-DDEFAULT_MAKESPEC="${CMAKE_NATIVE_MAKE_PROGRAM}")


set(CodeRootPath ${ISSQTTESTROOTDIR}/qtbase)
include_directories(${CodeRootPath}/3rdparty/tinycbor/src
                    ${CodeRootPath}/3rdparty/tinycbor/tests
                    ${CodeRootPath}/3rdparty/tinycbor/tests/encoder
                    ${CodeRootPath}/3rdparty/tinycbor/tests/parser
                    ${CodeRootPath}/tests/auto/other/qvariant_common
                    ${CodeRootPath}/tests/auto/corelib/kernel/qcoreapplication
                    ${CodeRootPath}/tests/baselineserver/shared
                    ${CodeRootPath}/tests/
                    ${CodeRootPath}/tests/auto/other/qabstractitemmodelutils
                    ${CodeRootPath}/tests/shared
                    ${CodeRootPath}/tests/auto/corelib/kernel/qmetatype)


#多级目录
set(TEST_ITEMS ${TEST_ITEMS}
    corelib/animation
    corelib/codecs
    corelib/global
    corelib/io
    corelib/itemmodels
    corelib/plugin/qlibrary
    corelib/plugin/qplugin
    corelib/plugin/quuid
    corelib/serialization
    corelib/statemachine
    corelib/thread
    corelib/tools

    #其他测试项需要
    other/qabstractitemmodelutils
)

#排出不需要的.cpp
set(EXCLUDE_SRC ${EXCLUDE_SRC}
    #private test
    corelib/io/qfileinfo/tst_qfileinfo.cpp 
    corelib/io/qfilesystementry/tst_qfilesystementry.cpp 
    corelib/io/qipaddress/tst_qipaddress.cpp 
    corelib/io/qloggingregistry/tst_qloggingregistry.cpp 
    corelib/io/qurlinternal/tst_qurlinternal.cpp 
    corelib/itemmodels/qstringlistmodel/tst_qurlinternal.cpp 
    corelib/kernel/qsharedmemory/tst_qsharedmemory.cpp 
    corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp
    corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
    corelib/mimetypes/qmimedatabase-cache/tst_qmimedatabase-cache.cpp
    corelib/mimetypes/qmimedatabase-xml/tst_qmimedatabase-xml.cpp 
    corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp 
    corelib/mimetypes/qmimetype/tst_qmimetype.cpp 
    corelib/serialization/qcborstreamreader/qcborstreamreader.cpp 
    corelib/serialization/qcborstreamwriter/tst_qcborstreamwriter.cpp 
    corelib/serialization/qcborvalue/tst_qcborvalue.cpp 
    corelib/tools/qfreelist/tst_qfreelist.cpp 
    corelib/tools/qsharedpointer/tst_qsharedpointer.cpp 
    corelib/tools/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp 
    corelib/tools/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp 
    corelib/tools/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp 
    corelib/tools/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp 
    #not win
    corelib/io/qprocess/testSoftExit/main_win.cpp 
    corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp
    #not test file
    corelib/serialization/cborlargedatavalidation.cpp 
    corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp 
    corelib/io/qlockfile/qlockfiletesthelper/qlockfile_test_helper.cpp 
    corelib/io/qprocess/testSoftExit/main_unix.cpp 
    corelib/kernel/qobject/signalbug/signalbug.cpp 
    corelib/thread/qthreadstorage/crashonexit/crashOnExit.cpp 
    corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp 
    corelib/tools/qlocale/syslocaleapp/syslocaleapp.cpp 
    corelib/tools/qsharedpointer/externaltests.cpp
    corelib/itemmodels/qitemmodel/modelstotest.cpp
    #no app
    corelib/io/qprocess-noapplication/tst_qprocessnoapplication.cpp
    corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
    corelib/global/qglobal/tst_qglobal.cpp
    #not support QProcess
    corelib/io/qprocess/tst_qprocess.cpp
    #need QGuiApplication/QCoreApplicaiton（在其他测试程序中）
    corelib/io/qsettings/tst_qsettings.cpp
    corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp
    corelib/serialization/qdatastream/tst_qdatastream.cpp
    corelib/tools/qpair/tst_qpair.cpp
    corelib/thread/qfuture/tst_qfuture.cpp
    corelib/thread/qthreadpool/tst_qthreadpool.cpp
    corelib/io/qstandardpaths/tst_qstandardpaths.cpp


    #todo：cppcrash
    corelib/itemmodels/qsortfilterproxymodel_regexp/tst_qsortfilterproxymodel_regexp.cpp                           #SIGSEGV
    corelib/itemmodels/qsortfilterproxymodel_regularexpression/tst_qsortfilterproxymodel_regularexpression.cpp     #SIGSEGV
    corelib/tools/qtimezone/tst_qtimezone.cpp                                                                      # qtimezone未适配
    corelib/serialization/qxmlstream/tst_qxmlstream.cpp                                                            #TestSuiteHandler::TestSuiteHandler(const QUrl &): baseURI must be valid
#    corelib/serialization/qtextstream/tst_qtextstream.cpp			                                               #probably caused by NULL pointer dereference
#    corelib/thread/qthreadstorage/tst_qthreadstorage.cpp                                                           #SIGSEGV(SEGV_MAPERR)@0x10ee00ca0000000f
    corelib/tools/qhash/tst_qhash.cpp                                                                              #SIGSEGV(SEGV_MAPERR)@0x0000005500000000
    corelib/tools/qlist/tst_qlist.cpp                                                                              #SIGSEGV(SEGV_ACCERR)@0x000000558f770000
    corelib/tools/qmap/tst_qmap.cpp                                                                                #SIGSEGV(SEGV_MAPERR)@0x0000005500000000
    corelib/tools/qregexp/tst_qregexp.cpp                                                                          #SIGSEGV(SEGV_ACCERR)@0x000000558ce743cc
    corelib/tools/qvector/tst_qvector.cpp                                                                          #SIGSEGV(SEGV_MAPERR)@000000000000000000  probably caused by NULL pointer dereference
#    corelib/statemachine/qstate/tst_qstate.cpp							                                           #probably caused by NULL pointer dereference
#    corelib/statemachine/qstatemachine/tst_qstatemachine.cpp			                                           #probably caused by NULL pointer dereference
#    corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp				                                           #probably caused by NULL pointer dereference
#    orelib/thread/qthread/tst_qthread.cpp                                                                         #probably caused by NULL pointer dereference

)

add_sources(
    gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp
    gui/kernel/qtouchevent/tst_qtouchevent.cpp
    gui/text/qfont/tst_qfont.cpp
    gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp
    gui/text/qtextobject/tst_qtextobject.cpp
    gui/painting/qpainter/tst_qpainter.cpp
    gui/painting/qtransform/tst_qtransform.cpp
    gui/util/qtexturefilereader/tst_qtexturefilereader.cpp
    gui/painting/qcolor/tst_qcolor.cpp
    gui/painting/qregion/tst_qregion.cpp
    gui/qopenglconfig/tst_qopenglconfig.cpp
    gui/qopenglconfig/tst_qopenglconfig.qrc
    gui/text/qrawfont/tst_qrawfont.cpp
    gui/text/qrawfont/testdata.qrc
    gui/image/qpixmap/tst_qpixmap.cpp
    gui/image/qpixmap/qpixmap.qrc
    gui/image/qmovie/tst_qmovie.cpp
)

set(PLUGINS QOpenHarmonyPlatformIntegrationPlugin)

#0为使用widget_main，1为使用gui_main,2使用core_main,3使用appless_main，4或其他使用none_main
set(MANUAL_ADD_MAIN 0)

#再把TEST_ITEMS传给create_library整合测试项，生成测试库
#整合测试项，生成测试库，名字当前工程名，即project(tst_qtcharts_auto)中定义的tst_qtcharts_auto
create_library(${TEST_ITEMS})




